package com.zbkj.admin.controller.platform.assistant;

import com.zbkj.admin.controller.platform.assistant.service.AssistantGroupAccountService;
import com.zbkj.common.model.assistant.AssistantGroupAccount;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.assistant.model.request.AssistantGroupAccountRequest;
import com.zbkj.service.assistant.model.request.AssistantGroupAccountSearchRequest;
import com.zbkj.service.assistant.model.vo.AssistantGroupAccountVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 客服分组人员关系表 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/platform/assistant/group-account")
@Api(tags = "客服-人员关系") //配合swagger使用
public class AssistantGroupAccountController {

    @Autowired
    private AssistantGroupAccountService assistantGroupAccountService;

    /**
     * 分页显示客服分组人员关系表
     * @param request 搜索条件
     * @param pageParamRequest 分页参数
     * @author zhuwy
     * @since 2025-06-18
     */
    @ApiOperation(value = "分页列表") //配合swagger使用
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<AssistantGroupAccountVO>>  getList(@Validated AssistantGroupAccountSearchRequest request, @Validated PageParamRequest pageParamRequest) {
        CommonPage<AssistantGroupAccountVO> assistantGroupAccountCommonPage = CommonPage.restPage(assistantGroupAccountService.getPage(request, pageParamRequest));
        return CommonResult.success(assistantGroupAccountCommonPage);
    }

//    /**
//     * 删除客服分组人员关系表
//     * @param id Integer
//     * @author zhuwy
//     * @since 2025-06-18
//     */
//    @ApiOperation(value = "删除")
//    @RequestMapping(value = "/delete", method = RequestMethod.GET)
//    public CommonResult<String> delete(@RequestParam(value = "id") Integer id) {
//        if(assistantGroupAccountService.removeById(id)) {
//            return CommonResult.success();
//        } else {
//            return CommonResult.failed();
//        }
//    }

    /**
     * 修改客服分组人员关系表
     * @param assistantGroupAccountRequest 修改参数
     * @author zhuwy
     * @since 2025-06-18
     */
    @ApiOperation(value = "修改")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public CommonResult<String> update(@RequestBody @Validated AssistantGroupAccountRequest assistantGroupAccountRequest) {
        AssistantGroupAccount assistantGroupAccount = new AssistantGroupAccount();
        BeanUtils.copyProperties(assistantGroupAccountRequest, assistantGroupAccount);

        if(assistantGroupAccountService.updateById(assistantGroupAccount)) {
            return CommonResult.success();
        } else {
            return CommonResult.failed();
        }
    }

    /**
     * 查询客服分组人员关系表信息
     * @param id Integer
     * @author zhuwy
     * @since 2025-06-18
     */
    @ApiOperation(value = "详情")
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public CommonResult<AssistantGroupAccount> info(@RequestParam(value = "id") Integer id) {
        AssistantGroupAccount assistantGroupAccount = assistantGroupAccountService.getById(id);
        return CommonResult.success(assistantGroupAccount);
    }
}



